<%-- 
    Document   : GetInfo
    Created on : Sep 30, 2011, 11:52:11 PM
    Author     : James
--%>

<%@page import="EntityState.ItemState"%>
<%@page import="EntityState.OutletState"%>
<%@page import="java.util.List"%>
<%@page import="EntityState.ItemCategoryState"%>
<%@page import="BusinessLogic.Constants"%>
<%@page import="java.util.ArrayList"%>
<%@page import="servlet.Cart"%>
<%@ page contentType="text/xml" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<getInfo>
<%
    ArrayList data = (ArrayList) request.getAttribute("data");
    int result = ((Integer) data.get(0)).intValue();
    if (result == Constants.STATUS_SESSION_EXPIRED) {
%>
<status>SESSION_EXPIRED</status>
<%
   } else if (result == Constants.STATUS_INVALID_INPUT) {
%>
<status>INVALID_INPUT</status>
<%
   } else if (result == Constants.STATUS_NOT_FOUND) {
%>
<status>NOT_FOUND</status>
<%
   } else if (result == Constants.STATUS_SUCCESSFUL) {
%>
<status>SUCCESSFUL</status>
<%
       int action = Integer.parseInt(request.getParameter("action"));
       if (action == Constants.GET_LIST_OF_PARTNER_CATEGORIES) {
%>
<categories>
<%
           List<ItemCategoryState> categories = (List<ItemCategoryState>) data.get(1);
           for (ItemCategoryState ics : categories) {
%>
    <category>
        <catID><%= ics.getId() %></catID>
        <catName><%= ics.getName() %></catName>
<%
                for (ItemState is : ics.getListOfItems()) {
%>
        <item>
            <itemID><%= is.getId() %></itemID>
            <itemName><%= is.getName() %></itemName>
        </item>
<%
               } 
%>
    </category>
<%
           }
%>
</categories>
<%
       } else if (action == Constants.GET_LIST_OF_OUTLETS) {
%>
<outlets>
<%
           List<OutletState> outlets = (List<OutletState>) data.get(1);
           for (OutletState os : outlets) {
%>
    <outlet>
        <id><%= os.getId() %></id>
        <name><%= os.getName() %></name>
    </outlet>
<%
           }
%>
</outlets>
<%
       } else if (action == Constants.GET_LIST_OF_OUTLET_ITEMS) {
%>
<items>
<%
           List<ItemState> items = (List<ItemState>) data.get(1);
           for (ItemState is : items) {
              
%>
    <anItem>
        <id><%= is.getId() %></id>
        <name><%= is.getName() %></name>
    </anItem>
<%
           }
%>
</items>
<%
       } 
%>

<%
   }
%>
</getInfo>